package matrice;

import jeuDeLaVie.Cellule;

public class Filtrage extends Matrice {

	private Matrice m;
	private int[] univers;
	
	public Filtrage(Matrice m, int[] univers){		
		this.m=m;
		this.univers = univers;
	}



	@Override
	public boolean hasNext() {
		return m.hasNext();
	}

	@Override
	public Poid next() {
		Poid p = m.next();		
		if(p.getCellule().getAbs()<univers[0] || p.getCellule().getAbs()>univers[1] || p.getCellule().getOrd()<univers[2] || p.getCellule().getOrd()>univers[3]){
			if(this.hasNext()){
				return this.next();
			}else{
				return new Poid(new Cellule(univers[1]+1,univers[3]+1),0);
			}				
		}else{
			return p;
		}	
	}
	

	
	
}
